// HALCON/Qt pattern matching and measure example
//
// (c) 2004-2016 MVTec Software GmbH

// QHalconWindow.h : Class used for opening HALCON windows in Qt
//
#ifndef QHALCONWINDOW_H
#define QHALCONWINDOW_H
#include <QWidget>
#include <QPainter>
#include <QScopedPointer>
#include <QTextBrowser>
#include <QDebug>
#include "HalconCpp.h"


class QHalconWindow : public QWidget
{
	Q_OBJECT

public:
	QHalconWindow(QWidget *parent = 0, long Width = 0, long Height = 0);
	void SetDispImageSize(Hlong wImage, Hlong hImage);
	//void SetDispParam(bool bResult);
	HalconCpp::HWindow* GetHalconBuffer(void) { return halconBuffer.data(); }
	// HalconCpp::HImage GetLatestImage(){return m_image;}
	// void SetLatestImage(HalconCpp::HImage image){m_image = image;}
	 /*bool IsLive(){ return m_bLive; }

	 void SetLive(bool b) {
		 m_bLive = b;
	 }*/
	 /*bool isProcessing() { return m_bProcessing; }
	 void SetProcessing(bool b) {
		 m_bProcessing = b;
	 }*/
	void InitHalconWindow();
	void ZoomIn();
	void ZoomOut();
protected:
	void resizeEvent(QResizeEvent*);
	void paintEvent(QPaintEvent *event);
	void mouseMoveEvent(QMouseEvent *event);
	void mousePressEvent(QMouseEvent *event);
	void mouseReleaseEvent(QMouseEvent *event);
	void mouseDoubleClickEvent(QMouseEvent *event);
	void wheelEvent(QWheelEvent *event);

private:
	void GetPartFloat(double *row1, double *col1, double *row2, double *col2);
	void SetPartFloat(double row1, double col1, double row2, double col2);
	QScopedPointer<HalconCpp::HWindow> halconBuffer;

	//  HalconCpp::HImage m_image;
	QPoint lastMousePos;
	double lastRow1, lastCol1, lastRow2, lastCol2;
};
#endif // QHALCONWINDOW_H